import React, { Component } from 'react'
// import qs from 'querystring'

export default class Detail extends Component {

    state = {
        detailList: [
            { id: '1', content: '11111' },
            { id: '2', content: '22222' },
            { id: '3', content: '33333' },
        ]
    }

    render() {
        // 接收params参数
        const { match: { params: { id, title } } } = this.props

        // 接收search参数
        // const search = this.props.location.search.slice(1)
        // const { id, title } = qs.parse(search)

        // 接收state参数
        // const { id, title } = this.props.location.state || {}

        const { content } = this.state.detailList.find(v => v.id === id) || {}
        return (
            <ul>
                <li>Id: {id}</li>
                <li>Title: {title}</li>
                <li>Content: {content}</li>
            </ul>
        )
    }
}
